package cn.oesoft.tennissystem.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/** 资源映射路径 */
@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {

    /** 保存的真实地址 */
    @Value("${file.upload.path}")
    String sysPath;

    /** 请求的相对地址 */
    @Value("${file.upload.relationImg}")
    String relationImg;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        /** 将相对地址映射到真实地址 */
        registry.addResourceHandler(relationImg+"**").addResourceLocations("file:/"+sysPath+relationImg);
    }
}
